package com.loginactivity.qingyuan;

import android.os.Environment;
import android.support.annotation.NonNull;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.util.Collection;
import java.util.EmptyStackException;
import java.util.EventListener;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * Created by Administrator on 2017/9/14.
 */

public class UserSaveInfo {
    public static boolean saveInfo(String name,String mima){
        String result=name+"##"+mima;
        String sdpth= Environment.getExternalStorageDirectory().getPath();
        File file=new File(sdpth,"info.text");
        try {
            FileOutputStream fos=new FileOutputStream(file);
            fos.write(result.getBytes());
            fos.close();
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
    public static Map<String,String> readInfo(){
        Map<String,String> map=new HashMap<>();
        String sdpth= Environment.getExternalStorageDirectory().getPath();
        File file=new File(sdpth,"info.text");
        try {
            FileInputStream fis=new FileInputStream(file);
            BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(fis));
            String content=bufferedReader.readLine();
            String spite[]=content.split("##");
            String name=spite[0];
            String mima=spite[1];
            map.put("name",name);
            map.put("mima",mima);
            fis.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return null;
    }
}
